#include<QObject>
#include<QTest>

#include<stdlib.h>

#include"LFMCrypter.h"

class TestLFMCrypter: public QObject{
Q_OBJECT
private:
	LFMCrypter *m_crypter;
private slots:
	void initTestCase(){
		m_crypter = new LFMCrypter;
	}
	
	void cleanupTestCase(){
		if(m_crypter)
			delete m_crypter;
	}
	
	void testCrypting(){
		QString input = "a very simple test string 123 \n\t xYz";
		QString intermediate = m_crypter->encrypt(input);
		QVERIFY(input != intermediate);
		
		QString output = m_crypter->decrypt(intermediate);
		QCOMPARE(input, output);
	}
	
	void testFiles(){
		QString input = "a very simple test string 123 \n\t xYz";
		m_crypter->encryptToFile(input, ".test_crypter");
		QString output = m_crypter->decryptFromFile(".test_crypter");
#ifdef linux
		system("rm .test_crypter");
#else
		system("del .test_crypter");
#endif
		QCOMPARE(input, output);
	}
};

QTEST_MAIN(TestLFMCrypter)
#include"TestLFMCrypter.moc"